package com.asialjim.wechat.pojo.account;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.JdbcType;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * <h1><em>ASIAL JIM JAVA DOC</em></h1><hr/>
 * <h2>CLASS DESCRIPTION <i>[ NAME: WeChatAccount ]</i></h2><strong>
 * <p> 微信公众平台账号
 * </strong><p><p><em>Copyright &copy; Asial Jim Co., LTD</em><hr/>
 *
 * @author Asial Jim &nbsp;&nbsp; <span>Email:<a href="mailto:asialjim@hotmail.com">asialjim@hotmail.com</a> &nbsp;&nbsp; <a href="asialjim@qq.com">asialjim@qq.com</a></span>
 * @version 1.0.0
 * @since 2021/1/27   &nbsp;&nbsp; JDK 8
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "T_WECHAT_ACCOUNT")
public class WeChatAccount implements Serializable {
    private static final long serialVersionUID = -3569794555473752098L;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 微信公众平台应用编号
     */
    @TableId(type = IdType.INPUT)
    private String appId;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 账号名称
     */
    private String name;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 账号状态
     */
    private WeChatAccountStatus state;
    public String getState(){return Objects.isNull(state) ? null : state.getName();}
    public void setState(String state){this.state = WeChatAccountStatus.nameOf(state);}

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 原始id，对应为公众平台应用的微信编号
     */
    private String subjectId;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 应用密码，用来换取accessToken
     */
    private String appSecret;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 开发者配置的令牌
     */
    private String token;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 开发者服务器地址
     */
    private String url;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 账户类型，公众号，小程序，小游戏等
     */
    private WeChatAccountType weChatAccountType;
    public String getWeChatAccountType(){return Objects.nonNull(weChatAccountType) ? this.weChatAccountType.getName() : null;}
    public void setWeChatAccountType(String weChatAccountType){this.weChatAccountType = WeChatAccountType.nameOf(weChatAccountType);}

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 账户类型，如订阅号，服务号，测试号等
     */
    private String accountType;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 加密密钥
     */
    @TableField(value = "ENCODING_AES_KEY")
    private String encodingAesKey;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 微信消息加密类型，明文模式，混合模式，安全模式三选一
     */
    private WeChatAccountMessageEncodingType encodingType;
    public String getEncodingType(){return Objects.nonNull(encodingAesKey) ? this.encodingType.getName() : null;}
    public void setEncodingType(String encodingType){this.encodingType = WeChatAccountMessageEncodingType.nameOf(encodingType);}

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 管理者OPEN ID
     */
    private String managerOpenId;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT,jdbcType = JdbcType.DATE)
    private Date createTime;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * 更新时间
     */
    @TableField(fill = FieldFill.UPDATE,jdbcType = JdbcType.DATE)
    private Date updateTime;

    private String openAccount;
}
